import {createRouter, createWebHistory} from "vue-router";

// import HomeView from "../views/HomeView.vue";        //静态导入，容易让js文件变大
// component:() => import("../views/HomeView.vue"),      //动态导入，可以分为多个小的js文件，加载变得更加顺利



const router = createRouter({
    history: createWebHistory(import.meta.env.BASE_URL),
    routes: [
        {
            path: "/",
            name: "home",
            component:() => import("../components/layout/AppLayout.vue"),       //外部框架
            meta: { requiresAuth: true, title: "首页" },
            children: [     //中间挖的窟窿
                {
                    path: "",
                    name: "default",
                    component:() => import("../views/DefaultView.vue"),
                    meta: { title: "默认页" },
                },
                {
                    path:'/:xxx(.*)*',      //没有找到匹配
                    name:'ErrorPage',
                    component:() => import('../components/layout/ErrorPage.vue'),
                    meta: { title: "错误页" },
                },
                {
                    path: "/about",
                    name: "about",  //这种路由加载方式是懒加载
                    component:() => import("../views/AboutView.vue"),
                    meta: { title: "关于页" },
                },
                ///link
                {
                    path:"/finsh",
                    name: "finsh",
                    component:() => import("../views/link/FinSHView.vue"),
                    meta: { title: "串口终端页" ,keepAlive: true},// 启用组件缓存
                },
                {
                    path:"/ethernet",
                    name: "ethernet",
                    component:() => import("../views/link/EthernetView.vue"),
                    meta: { title: "网口通信页" },
                },
                {
                    path:"/modbus",
                    name: "modbus",
                    component:() => import("../views/link/ModbusView.vue"),
                    meta: { title: "Modbus协议通信页" },
                },
                ///Monitor
                {
                    path:"/sensor",
                    name: "sensor",
                    component:() => import("../views/monitor/SensorView.vue"),
                    meta: { title: "传感器页" },
                },
                {
                    path:"/controller",
                    name: "controller",
                    component:() => import("../views/monitor/ControllerView.vue"),
                    meta: { title: "控制器页" },
                },
                {
                    path:"/memory",
                    name: "memory",
                    component:() => import("../views/monitor/MemoryView.vue"),
                    meta: { title: "内存状态页" },
                },
                {
                    path:"/network",
                    name: "network",
                    component:() => import("../views/monitor/NetworkView.vue"),
                    meta: { title: "网络状态页" },
                },
            ]
        },
    ]
})


export default router       //声明导出，可以让main.js使用


